#include <iostream>
#include <string>
#include <algorithm>
#include <filesystem>

using namespace std;

void solve() {
    string s, op;
    int n, x, sum = 0;
    int f = 1;
    
    cin >> s >> n;
    int len = s.size();
    
    while(n--) {
        cin >> op;
        if(op == "<") {
            cin >> x;
            if(f == 1) sum -= x;
            else sum += x;
        } 
        if(op == ">") {
            cin >> x;
            if(f == 1) sum += x;
            else sum -= x;
        }
        if(op == "rev") {
            f = 1 - f;
        }
    }
    
    sum %= len;
    if(sum < 0) {
        sum = abs(sum);
        rotate(s.begin(), s.begin() + sum, s.end());
    } else {
        rotate(s.rbegin(), s.rbegin() + sum, s.rend());
    }
    if(f == 0) reverse(s.begin(), s.end());
    
    cout << s;
}

int main() {
    // 创建sample目录
    filesystem::create_directory("sample");
    
    // 处理data目录下的所有测试数据
    for(int i = 1; i <= 10; i++) {
        string in_file = "data/string" + to_string(i) + ".in";
        string out_file = "data/string" + to_string(i) + ".out";
        
        freopen(in_file.c_str(), "r", stdin);
        freopen(out_file.c_str(), "w", stdout);
        
        solve();
        
        // 如果是第1、2、3组数据，复制到sample目录
        if(i <= 3) {
            string sample_in = "sample/string" + to_string(i) + ".in";
            string sample_out = "sample/string" + to_string(i) + ".ans";
            filesystem::copy_file(in_file, sample_in, filesystem::copy_options::overwrite_existing);
            filesystem::copy_file(out_file, sample_out, filesystem::copy_options::overwrite_existing);
        }
    }
    
    return 0;
} 